package com.honey.compilation.sql.ddl;

import java.util.ArrayList;
import java.util.List;

import com.honey.compilation.sql.SqlKeyWord;
import com.honey.compilation.sql.SqlScript;
import com.honey.core.builder.CharacterBuilder;
import com.honey.core.builder.CharacterBuilderFactory;
import com.honey.core.compiler.CompilationException;
import com.honey.core.utils.StringUtility;

/**
 * Set命令扩充
 * 
 * @author Administrator
 *
 */
public class SetAppend extends Set implements SqlScript{
	
	/** 追加内容 */
	private List<String> appends= null;
	
	/**
	 * 构造函数
	 * @param appends 追加内容
	 */
	public SetAppend( String ...appends){
		this.appends = new ArrayList<String>();
		addAppend(appends);
	}
	
	/**
	 * 设定追加内容
	 * @param appends
	 */
	public void addAppend(String ...appends) {
		for( String append :appends ){
			if(StringUtility.stringHasValue(append)){
				this.appends.add(append);
			}
		}
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.honey.core.dom.sql.ddl.Set#compiledContent(int)
	 */
	@Override
	public CharacterBuilder compiledContent(int indentLevel )throws CompilationException {
		CharacterBuilder answer = CharacterBuilderFactory.createC16StringBuilder();
		if( appends.size() > 0){
			answer.append(super.compiledContent(indentLevel));
			for(String append :appends ){
				answer.append(append);
			}
			answer.append(SqlKeyWord.OPERATION_SEMICOLON);
		}
		return answer;
	}
}
